<?php
/*
// by using PEAR-type naming conventions, autoload will always know where to
	// find class definitions
	function YommAutoLoader($class) {
		
		if(substr($class, 0, 6) == "Smarty")
			return;
		
		if(substr($class, 0, 6) == "Devmod")
			return;
		
		$file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
			
		if(!file_exists($file)) {
			new Yomm_Alias($class);
		} else {
			require_once($file);
		}
	}
	
	spl_autoload_register("YommAutoLoader");
*/

	/**
	 * @package Yomm
	 * @author bsuter
	 *
	 */
	Class Yomm_Loader
	{
		
		private $_filters = array();
		
		public function addPrefixFilter($prefix)
		{
			$this->_filters[] = array(
				'name' => $prefix,
				'length' => strlen($prefix)
			);
		}
		
		public function start()
		{
			spl_autoload_register(array($this, 'loader'));
		}
		
		private function loader($class)
		{
			foreach($this->_filters as $filter)
			{
				if(substr($class, 0, $filter['length']) == $filter['name'])
				return;
			}
			
			$file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.class.php';
				
			if(!file_exists($file)) {
				new Yomm_Alias($class);
			} else {
				require_once($file);
			}
		}
	}